<template>
  <view class="page-wrapper">
    <scroll-view scroll-y class="page-scroll" :style="{ height: scrollHeight + 'px' }">
      <view class="container">
        <!-- 顶部导航 -->
        <view class="nav-header">
          <view class="left">
            <view class="back-home">
              <text class="back">←</text>
              <text class="divider">|</text>
              <text class="home">⌂</text>
            </view>
          </view>
          <view class="right">
            <button class="share-btn">
              <image src="/static/images/wechat.png" mode="aspectFit"></image>
              分享
            </button>
            <text class="more">•••</text>
            <text class="record">⦿</text>
          </view>
        </view>

        <!-- VR标签 -->
        <view class="vr-badge">
          VR语音带看
        </view>

        <!-- 图片轮播 -->
        <swiper class="gallery-swiper" :indicator-dots="true" :autoplay="true" interval="3000" duration="500">
          <swiper-item v-for="(image, index) in houseImages" :key="index">
            <image :src="image" mode="aspectFill"></image>
          </swiper-item>
        </swiper>

        <!-- 图片分类标签 -->
        <view class="image-tabs">
          <text class="tab">VR</text>
          <text class="tab active">图片 (7)</text>
          <text class="tab">户型</text>
          <text class="tab">装修实感</text>
        </view>

        <!-- 店铺推荐banner -->
        <view class="store-banner">
          <image src="/static/images/store-icon.png" mode="aspectFit"></image>
          <text>必看好房</text>
          <text class="dot">·</text>
          <text class="highlight">店长推荐·三层严选</text>
        </view>

        <!-- 房屋信息 -->
        <view class="house-info">
          <!-- 标题 -->
          <view class="title">
            本小区实惠湖景四房，人车分流高绿化，地铁和商圈为邻
          </view>

          <!-- 标签 -->
          <view class="tags">
            <text class="tag">近地铁</text>
            <text class="tag">随时看房</text>
            <text class="tag">VR看房</text>
            <view class="action-btns">
              <button class="action-btn">
                <text class="pk-icon">PK</text>
                对比
              </button>
              <button class="action-btn">
                <text class="heart-icon">♡</text>
                关注
              </button>
            </view>
          </view>

          <!-- 价格信息 -->
          <view class="price-section">
            <view class="price-item">
              <view class="price">
                <text class="amount">275</text>
                <text class="unit">万</text>
              </view>
              <text class="label">售价</text>
            </view>
            <view class="price-item">
              <text class="type">4室2厅</text>
              <text class="label">房型</text>
            </view>
            <view class="price-item">
              <text class="area">128.57m²</text>
              <text class="label">建筑面积</text>
            </view>
          </view>

          <!-- 快捷操作 -->
          <view class="quick-actions">
            <button class="action-btn">
              <image src="/static/images/vr-icon.png" mode="aspectFit"></image>
              VR语音带看
            </button>
            <button class="action-btn">
              <image src="/static/images/live-icon.png" mode="aspectFit"></image>
              直播附近好房
            </button>
          </view>

          <!-- 房屋详情 -->
          <view class="detail-list">
            <view class="detail-item">
              <text class="label">单价</text>
              <text class="value">21390元/平</text>
            </view>
            <view class="detail-item">
              <text class="label">楼层</text>
              <text class="value">高楼层/33</text>
              <text class="action">咨询楼层</text>
              <text class="arrow">></text>
            </view>
            <view class="detail-item">
              <text class="label">套内</text>
              <text class="value">暂无数据</text>
              <text class="action">咨询套内使用面积</text>
              <text class="arrow">></text>
            </view>
            <view class="detail-item">
              <text class="label">挂牌</text>
              <text class="value">2024.08.03</text>
            </view>
            <view class="detail-item">
              <text class="label">朝向</text>
              <text class="value">南</text>
            </view>
            <view class="detail-item">
              <text class="label">电梯</text>
              <text class="value">有电梯</text>
            </view>
            <view class="detail-item">
              <text class="label">权属</text>
              <text class="value">商品房</text>
            </view>
            <view class="detail-item">
              <text class="label">用途</text>
              <text class="value">普通住宅</text>
            </view>
            <view class="detail-item">
              <text class="label">装修</text>
              <text class="value">毛坯房，重新装修约18.1万</text>
              <text class="arrow">></text>
            </view>
            <view class="detail-item">
              <text class="label">小区</text>
              <text class="value">天铂</text>
              <text class="arrow">></text>
            </view>
          </view>

          <!-- 降价通知 -->
          <view class="price-notice">
            <image src="/static/images/price-down.png" mode="aspectFit"></image>
            <text>该房源近期降价5万元，抢先咨询</text>
            <text class="arrow">></text>
          </view>

          <!-- 经纪人信息 -->
          <view class="agent-info">
            <image class="avatar" src="/static/images/agent.png" mode="aspectFit"></image>
            <view class="agent-detail">
              <view class="name-row">
                <text class="name">周宗金</text>
                <image class="verify-badge" src="/static/images/verified.png" mode="aspectFit"></image>
              </view>
              <text class="title">住商</text>
            </view>
            <view class="contact-btns">
              <button class="call-btn">打电话</button>
              <button class="chat-btn">
                在线问
                <text class="recent">近期咨询过</text>
              </button>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  name: 'HouseDetail',
  data() {
    return {
      scrollHeight: 0,
      houseImages: [
        '/static/images/house1.jpg',
        '/static/images/house2.jpg',
        '/static/images/house3.jpg'
      ]
    }
  },
  onLoad() {
    // 获取系统信息设置滚动区域高度
    const systemInfo = uni.getSystemInfoSync()
    this.scrollHeight = systemInfo.windowHeight
  }
}
</script>

<style lang="scss" scoped>
.page-wrapper {
  height: 100vh;
  background: #f8f8f8;
}

.page-scroll {
  .container {
    position: relative;
  }
}

.nav-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 12rpx 24rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .back-home {
    background: rgba(0,0,0,0.3);
    border-radius: 36rpx;
    padding: 8rpx 20rpx;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8rpx;
    font-size: 28rpx;

    .divider {
      opacity: 0.6;
      margin: 0 6rpx;
    }
  }

  .right {
    display: flex;
    align-items: center;
    gap: 12rpx;

    .share-btn {
      background: rgba(0,0,0,0.3);
      border: none;
      color: #fff;
      font-size: 24rpx;
      padding: 8rpx 16rpx;
      border-radius: 28rpx;
      display: flex;
      align-items: center;
      gap: 4rpx;
      line-height: 1;
      height: 52rpx;

      image {
        width: 28rpx;
        height: 28rpx;
      }
    }

    .more, .record {
      width: 52rpx;
      height: 52rpx;
      background: rgba(0,0,0,0.3);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-size: 28rpx;
    }
  }
}

.vr-badge {
  position: fixed;
  top: 88rpx;
  right: 24rpx;
  z-index: 100;
  background: rgba(0,0,0,0.3);
  color: #fff;
  padding: 6rpx 16rpx;
  border-radius: 24rpx;
  font-size: 22rpx;
}

.gallery-swiper {
  height: 500rpx;
  
  image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.image-tabs {
  display: flex;
  gap: 40rpx;
  padding: 24rpx 30rpx;
  background: #fff;
  border-bottom: 1px solid #f5f5f5;

  .tab {
    color: #666;
    font-size: 26rpx;
    position: relative;
    padding-bottom: 24rpx;

    &.active {
      color: #333;
      font-weight: 500;

      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 40rpx;
        height: 4rpx;
        background: #e4393c;
        border-radius: 2rpx;
      }
    }
  }
}

.store-banner {
  background: #e4393c;
  color: #fff;
  padding: 16rpx 24rpx;
  display: flex;
  align-items: center;
  gap: 8rpx;
  font-size: 26rpx;

  image {
    width: 36rpx;
    height: 36rpx;
  }

  .dot {
    opacity: 0.8;
    margin: 0 6rpx;
  }

  .highlight {
    font-weight: 500;
  }
}

.house-info {
  background: #fff;
  padding: 24rpx;

  .title {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
    margin-bottom: 20rpx;
  }

  .tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12rpx;
    margin-bottom: 24rpx;

    .tag {
      background: #f7f8fa;
      color: #666;
      padding: 4rpx 12rpx;
      border-radius: 4rpx;
      font-size: 22rpx;
    }

    .action-btns {
      margin-left: auto;
      display: flex;
      gap: 24rpx;

      .action-btn {
        display: flex;
        align-items: center;
        gap: 6rpx;
        background: none;
        border: none;
        font-size: 26rpx;
        color: #666;
        padding: 0;
        line-height: 1;

        .pk-icon {
          background: #f5f5f5;
          padding: 4rpx 8rpx;
          border-radius: 4rpx;
          font-size: 22rpx;
          margin-right: 4rpx;
        }

        .heart-icon {
          font-size: 32rpx;
          color: #999;
          margin-right: 4rpx;
        }
      }
    }
  }

  .price-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32rpx;
    border-bottom: 16rpx solid #f7f8fa;
    padding-bottom: 32rpx;

    .price-item {
      display: flex;
      flex-direction: column;
      align-items: flex-start;

      .price {
        display: flex;
        align-items: baseline;

        .amount {
          font-size: 52rpx;
          color: #e4393c;
          font-weight: 500;
          line-height: 1;
        }

        .unit {
          font-size: 26rpx;
          color: #e4393c;
          margin-left: 4rpx;
        }
      }

      .type, .area {
        font-size: 32rpx;
        color: #333;
        font-weight: 500;
      }

      .label {
        font-size: 22rpx;
        color: #999;
        margin-top: 6rpx;
      }
    }
  }

  .quick-actions {
    display: flex;
    gap: 16rpx;
    margin-bottom: 32rpx;

    .action-btn {
      flex: 1;
      background: #f7f8fa;
      border: none;
      padding: 20rpx;
      border-radius: 6rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8rpx;
      font-size: 26rpx;
      color: #333;
      height: 88rpx;

      image {
        width: 32rpx;
        height: 32rpx;
      }
    }
  }

  .detail-list {
    .detail-item {
      display: flex;
      align-items: center;
      padding: 24rpx 0;
      border-bottom: 1px solid #f5f5f5;
      font-size: 26rpx;

      .label {
        width: 100rpx;
        color: #999;
      }

      .value {
        flex: 1;
        color: #333;
      }

      .action {
        color: #1890ff;
        margin-left: 16rpx;
      }

      .arrow {
        color: #999;
        margin-left: 8rpx;
      }
    }
  }

  .price-notice {
    margin: 24rpx 0;
    background: rgba(0,0,0,0.7);
    padding: 16rpx 24rpx;
    border-radius: 6rpx;
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 26rpx;

    image {
      width: 28rpx;
      height: 28rpx;
      margin-right: 12rpx;
    }

    .arrow {
      margin-left: auto;
    }
  }

  .agent-info {
    display: flex;
    align-items: center;
    padding: 24rpx 0;

    .avatar {
      width: 88rpx;
      height: 88rpx;
      border-radius: 50%;
      margin-right: 16rpx;
    }

    .agent-detail {
      flex: 1;

      .name-row {
        display: flex;
        align-items: center;
        gap: 6rpx;
        margin-bottom: 6rpx;

        .name {
          font-size: 30rpx;
          font-weight: 500;
          color: #333;
        }

        .verify-badge {
          width: 24rpx;
          height: 24rpx;
        }
      }

      .title {
        font-size: 22rpx;
        color: #999;
      }
    }

    .contact-btns {
      display: flex;
      gap: 12rpx;

      button {
        height: 72rpx;
        padding: 0 24rpx;
        border-radius: 6rpx;
        font-size: 26rpx;
        display: flex;
        align-items: center;
        justify-content: center;

        &.call-btn {
          background: #fff;
          border: 1px solid #e4393c;
          color: #e4393c;
          min-width: 120rpx;
        }

        &.chat-btn {
          background: #e4393c;
          color: #fff;
          border: none;
          display: flex;
          flex-direction: column;
          min-width: 160rpx;

          .recent {
            font-size: 18rpx;
            opacity: 0.8;
            margin-top: 2rpx;
          }
        }
      }
    }
  }
}
</style>
